package com.treasure.hunt.api

import com.module.lemlin.mode.SubscribeListener
import com.module.lemlin.rxhttp.HttpServiceData
import com.treasure.hunt.api.subscribe.subscribe
import com.treasure.hunt.entity.LuckyReceiveResponse
import com.treasure.hunt.entity.LuckySignResponse
import com.treasure.hunt.entity.TaskDayResponse
import com.treasure.hunt.entity.TaskSignResponse
import io.reactivex.rxjava3.disposables.Disposable
import rxhttp.RxHttp

/**
 * 每日签到列表
 * */
fun taskSignList(
    listener: SubscribeListener<TaskSignResponse>
): Disposable = subscribe(
    RxHttp.get("/api/task/sign_in_list")
        .asClass(TaskSignResponse::class.java)
    , listener
)

/**
 * 签到
 * */
fun taskSign(
    signId: Int, videoLogId:String, isDouble: Int, listener: SubscribeListener<LuckySignResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/task/sign_in")
        .add("sign_id", signId)
        .add("video_log_id", videoLogId)
        .add("is_double", isDouble)
        .asClass(LuckySignResponse::class.java)
    , listener
)

/**
 * 日常任务列表
 * */
fun taskDayList(
    listener: SubscribeListener<TaskDayResponse>
): Disposable = subscribe(
    RxHttp.get("/api/task/day_task_list")
        .asClass(TaskDayResponse::class.java)
    , listener
)

/**
 * 完成任务
 * */
fun taskFinish(
    taskId: Int, listener: SubscribeListener<LuckyReceiveResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/task/finish_the_task")
        .add("task_id", taskId)
        .asClass(LuckyReceiveResponse::class.java)
    , listener
)

/**
 * 完成分享
 * 1=微信，2=QQ
 * */
fun taskShare(
    type: Int, listener: SubscribeListener<HttpServiceData>
): Disposable = subscribe(
    RxHttp.get("/api/task/share_task")
        .add("type", type)
        .asClass(HttpServiceData::class.java)
    , listener
)

